//操作系统os模块
//os==> operation system
const os = require('os');
//cpuinfo当前机器的cpu信息
const cpuinfo = os.cpus();
//
const memory = os.freemem();
//http
const http = require('http');

const server = http.createServer();

//监听request事件
server.on('request',function(req,res){
	const url = req.url;
	if(url == '/mycpuinfo'){
		res.end(JSON.stringify(cpuinfo));
	}else if(url == '/mymemory'){
		res.end(JSON.stringify(memory));
	}else{
		res.end('NONE');
	}
});

//绑定端口号:
server.listen(3000,function(){
	console.log("端口3000开启成功，请通过localhost:3000访问");
});
